package com.syas.dao.daos;

import com.syas.base.dao.daos.EntityDao;
import com.syas.dao.interfaces.ITargetDao;
import com.syas.model.models.Target;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by weigong on 2015/12/5.
 */
@Repository("TargetDao")
public class TargetDao extends EntityDao<Integer, Target> implements ITargetDao {

    @Override
    public List<Target> getTargetList() {
        return (List<Target>)this.getSession().createQuery("from Target").list();
    }

    @Override
    public List<Target> getTargetListByCitygrade(String citygrade) {
        return (List<Target>)this.getSession().createQuery("from Target as t where t.citygrade = ?").setParameter(0,citygrade).list();
    }


    public Target getTargetByGrageCode(String citygrade,String gradeCode) {
        return (Target)this.getSession().createQuery("from Target where citygrade=? and gradecode=?").setParameter(0, citygrade).setParameter(1, gradeCode).uniqueResult();
    }

}
